(server-start)
(add-hook 'server-switch-hook
	  (lambda nil
	    (let ((server-buf (current-buffer)))
	      (bury-buffer)
	      (switch-to-buffer-other-frame server-buf))))
(add-hook 'server-done-hook 'delete-frame)
(add-hook 'server-done-hook
	  (lambda nil
	    (kill-buffer nil)))
;;http://www.emacswiki.org/emacs/SettingFrameColorsForEmacsClient

;; (defun setup-window-system-frame-colours (&rest frame)
;;   (if window-system
;;       (let ((f (if (car frame)
;; 		   (car frame)
;; 		 (selected-frame))))
;; 	(progn
;; 	  (set-frame-font "Bera Sans Mono-11")
;; 	  (set-face-background 'default "#232F2F" f)
;; 	  (set-face-foreground 'default "#FFFFFF" f)
;; 	  (set-face-background 'fringe  "#000000" f)
;; 	  (set-face-background 'cursor "#2F4F4F" f)
;; 	  (set-face-background 'mode-line "#2F4F4F" f)
;; 	  (set-face-foreground 'mode-line "#BCBf91" f)))))

;; (require 'server)
;; (defadvice server-create-window-system-frame
;;   (after set-window-system-frame-colours ())
;;   "Set custom frame colours when creating the first frame on a display"
;;   (message "Running after frame-initialize")
;;   (setup-window-system-frame-colours))
;; (ad-activate 'server-create-window-system-frame)
;; (add-hook 'after-make-frame-functions 'setup-window-system-frame-colours t)

;;http://emacser.com/daemon.htm
;; (defun frame-setting ()
;;     (set-frame-font "文泉驿等宽微米黑 8")
;;     (set-fontset-font "fontset-default"
;; 		      'gb18030 '("文泉驿等宽微米黑" . "unicode-bmp")))
 
;; (if (and (fboundp 'daemonp) (daemonp))
;;     (add-hook 'after-make-frame-functions
;; 	      (lambda (frame)
;; 		(with-selected-frame frame
;; 		  (frame-setting))))
;;   (frame-setting))

;; (setq window-system-default-frame-alist
;;       '(
;;         ;; if frame created on x display
;;         (x
;; 	 (menu-bar-lines . 1)
;; 	 (tool-bar-lines . nil)
;; 	 ;; mouse
;; 	 (mouse-wheel-mode . 1)
;; 	 (mouse-wheel-follow-mouse . t)
;; 	 (mouse-avoidance-mode . 'exile)
;; 	 ;; face
;; 	 (font . "文泉驿等宽微米黑 8")
;; 	 )
;;         ;; if on term
;;         (nil
;; 	 (menu-bar-lines . 0) (tool-bar-lines . 0)
;; 	 ;; (background-color . "black")
;; 	 ;; (foreground-color . "white")
;; 	 )
;; 	)
;;      )



(provide 'emacs-server-settings)